package com.tdam2013.grupo01;

import java.util.List;

import com.tdam2013.grupo01.R;
import com.tdam2013.grupo01.EmailItem;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class CustomListEmailAdapter  extends ArrayAdapter<EmailItem> {

	Context context;

	public CustomListEmailAdapter(Context context, int resourceId,
			List<EmailItem> items) {
		super(context, resourceId, items);
		this.context = context;
	}
	
	   /*private view holder class*/
	   private class ViewHolder {
	       TextView txtEmail;
	   }
	   
	   public View getView(int position, View convertView, ViewGroup parent) {
	       ViewHolder holder = null;
	       EmailItem emailItem = getItem(position);

	       LayoutInflater mInflater = (LayoutInflater) context
	               .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
	       if (convertView == null) {
	           convertView = mInflater.inflate(R.layout.emailitem, null);
	           holder = new ViewHolder();
	           holder.txtEmail = (TextView) convertView.findViewById(R.id.txtEmail);
	           convertView.setTag(holder);
	       } else
	           holder = (ViewHolder) convertView.getTag();

	       holder.txtEmail.setText(emailItem.getEmail());

	       return convertView;
	   }
}
 